package com.foreknow.dao;

import com.foreknow.entity.User;
import org.apache.commons.dbutils.ResultSetHandler;

import java.sql.SQLException;
import java.util.List;

public interface IBaseDao<T> {
  /**
   * 删除
   * @param sql
   * @param params
   * @return
   * @throws SQLException
   */
  public int delete(String sql,Object...params) throws SQLException;
  /**
   * 删除
   * @param sql
   * @return
   * @throws SQLException
   */
  public int delete(String sql) throws SQLException;

  /**
   * 添加操作
   * @param sql
   * @param params
   * @return
   * @throws SQLException
   */
  public int insert(String sql,Object[] params)throws SQLException;

  /**
   * 条件查询
   * @param sql
   * @return
   * @throws SQLException
   */
  public List<T> queryByCondition(String sql)throws SQLException;

  /**
   * 条件查询
   * @param sql
   * @param params
   * @return
   * @throws SQLException
   */
  public List<T> queryByCondition(String sql,Object...params)throws SQLException;

  /**
   * 查询一个对象
   * @param sql
   * @param param
   * @return
   * @throws SQLException
   */
  public T queryOne(String sql,Object param) throws SQLException;

  /**
   * 动态
   * @param sql
   * @param params
   * @return
   * @throws SQLException
   */
  public User queryOne(String sql, Object[] params) throws SQLException;

  /**
   * 修改操作
   * @param sql
   * @param params
   * @return
   * @throws SQLException
   */
  public int update(String sql,Object...params)throws SQLException;

  /**
   * 修改操作
   * @param sql
   * @param param
   * @return
   * @throws SQLException
   */
  public int update(String sql,Object param)throws SQLException;

  /**
   * ResultSetHandler接口就是将ResultSet结果集映射为Bean、List、Map等Java中的对象或者集合。
   * @return
   */
  public ResultSetHandler<T> getResultSetHandler();

}
